<template>
  <div>
    <div class="common_form_search">
      <el-form ref="searchForm" :inline="true" :model="searchForm">
        <el-form-item label="ID" prop="orderID">
          <el-input v-model="searchForm.orderID" placeholder="请输入ID" clearable />
        </el-form-item>
        <el-form-item label="订单号" prop="trade_no">
          <el-input v-model="searchForm.trade_no" placeholder="请输入订单号" clearable />
        </el-form-item>
        <el-form-item label="用户名" prop="cert_name">
          <el-input v-model="searchForm.cert_name" placeholder="请输入订单号" clearable />
        </el-form-item>
        <el-form-item label="手机号" prop="mobile">
          <el-input v-model="searchForm.mobile" placeholder="请输入订单号" clearable />
        </el-form-item>
        <el-form-item>
          <el-button size="small" type="primary" @click="search()">查询</el-button>
          <el-button size="small" @click="reset()">重置</el-button>
        </el-form-item>
      </el-form>
    </div>
    <el-divider />
    <div class="flex align-center table-top-btns">
      <h5 class="flex align-center">
        <svg-icon style="margin-right:15px" icon-class="list" :size="15" />数据列表
      </h5>
    </div>
    <el-table v-show="tableData.length > -1" :data="tableData" border>
      <el-table-column align="center" prop="id" label="ID" width="50" />
      <el-table-column align="center" prop="trade_no" label="订单号" />
      <el-table-column align="center" prop="cert_name" label="姓名" width="70" />
      <el-table-column align="center" label="电话" prop="mobile" />
      <el-table-column align="center" label="身份证" prop="cert_no" />
      <el-table-column align="center" label="商户" prop="shopname" />
      <el-table-column align="center" label="查看征信时间" prop="start_at" width="110" />
      <el-table-column align="center" label="申请报送时间" prop="result1_time" width="110" />
      <el-table-column align="center" label="放款报送时间" prop="result2_time" width="110" />
      <el-table-column align="center" prop="result" label="征信查询结果" width="100">
        <template slot-scope="scope">
          <el-tooltip class="item" effect="dark" placement="top-start">
            <div slot="content" style="width:300px">{{scope.row.result == null ? '无' : scope.row.result}} </div>
            <el-tag :type="scope.row.result == null ? '' : 'success'">
              {{ scope.row.result == null ? '无' : '已申报' }}
            </el-tag>
          </el-tooltip>
        </template>
      </el-table-column>
      <el-table-column align="center" label="申请报送" prop="result1" >
        <template slot-scope="scope">
          <el-tooltip class="item" effect="dark" placement="top-start">
            <div slot="content" style="width:300px">{{scope.row.result1 == null ? '无' : scope.row.result1}} </div>
            <el-tag :type="scope.row.result1 == null ? '' : 'success'">
              {{ scope.row.result1 == null ? '无' : '已申报' }}
            </el-tag>
          </el-tooltip>
        </template>
      </el-table-column>
      <el-table-column align="center" label="放款报送" prop="result2" >
        <template slot-scope="scope">
          <el-tooltip class="item" effect="dark" :content="scope.row.result2 == null ? '无' : scope.row.result2" placement="top-start">
            <div slot="content" style="width:300px">{{scope.row.result2 == null ? '无' : scope.row.result2}} </div>
            <el-tag :type="scope.row.result2 == null ? '' : 'success'">
              {{ scope.row.result2 == null ? '无' : '已申报' }}
            </el-tag>
          </el-tooltip>
        </template>
      </el-table-column>
      <el-table-column fixed="right" align="center" label="操作" width="110">
        <template slot-scope="scope">
          <el-button type="primary" size="mini" @click="handleRemark(scope.row.id)">报送记录</el-button>
        </template>
      </el-table-column>
    </el-table>
    <custom-page ref="customPage" :total="total" @getList="getList" />
    <check-lease ref="checkLease" :order-id="orderId" />
    <credit-lease ref="creditLease" :order-id="orderId" />
  </div>
</template>

<script>
import { creditOrderList } from '@/api/order'
import customPage from '@/components/customPage'
// import checkLease from './dialogs/checklease'
import creditLease from './dialogs/creditLease'
export default {
  components: { customPage, creditLease },
  props: {
    shopname: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      searchForm: {
        orderID: '',
        trade_no: '',
        cert_name: '',
        mobile: ''
      },
      total: 0,
      tableData: [],
      routerName: '',
      orderId: 15122
    }
  },
  created() {
    if (this.$route.query.shopname) {
      this.routerName = this.$route.query.shopname
    }
  },
  mounted() {
    this.getList()
  },
  methods: {
    handleRemark(id) {
      this.orderId=id
      this.$refs.creditLease.dialogVisible = true
    },
    // 查询
    search() {
      this.$refs.customPage.page = 1
      this.getList()
    },
    // 重置
    reset() {
      this.searchForm = {
        shopname: '',
        account_num: '',
        status: null
      }
      this.routerName = ''
      this.getList()
    },
    getList(flag) {
      // flag为true, 则不刷新表格
      const { page, pageSize } = this.$refs.customPage
      if (!flag) {
        this.tableData = []
      }
      creditOrderList({ page, pageSize, ...this.searchForm }).then(res => {
        this.tableData = res.data || []
        this.total = res.total
      })
    }
  }
}
</script>

<style lang="scss" scoped>
</style>
